# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import numpy
import scipy
import requests
import os
from bs4 import BeautifulSoup

from vector.Vector import Vector

# if __name__ == '__main__':
#     try:
#         r = requests.get("http://www.baidu.com/s", params={"wd": "python"})
#         r.raise_for_status()
#         r.encoding = r.apparent_encoding
#         print(r.text)
#     except:
#         print("爬取失败")
# if __name__ == '__main__':
#     try:
#         if not os.path.exists("I:/test"):
#             os.mkdir("I:/test")
#         else:
#             r = requests.get("https://www.runoob.com/wp-content/themes/runoob/assets/img/thumbnail.png")
#         with open("I:/test/test.png", "wb") as f:
#             f.write(r.content)
#             f.close()
#     except:
#         print("爬取失败")
# https://www.runoob.com/w3cnote
if __name__ == '__main__':
    try:
        r = requests.get("https://www.runoob.com/w3cnote", params={})
        r.raise_for_status()
        r.encoding = r.apparent_encoding
        soup = BeautifulSoup(r.text, "html.parser")
        find_all = soup.find_all(attrs={"class": "archive-list-item"})
        for item in find_all[:find_all.__len__()-1]:
            print(item.div.h2.a.string)
    except:
        print("爬取失败")
# Press the green button in the gutter to run the script.
# if __name__ == '__main__':
#     print_hi('PyCharm')
#     print(Vector([2, 3]))
# print(Vector.zero(2))
# print([0]*2)
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
